package sebastiankerckhof.scene.transformation;

import sebastiankerckhof.math.Matrix4f;
import sebastiankerckhof.math.Vector3f;

public class Translation implements Transformation{
	Vector3f trans;
  public Translation(Vector3f trans){
  	this.trans = trans;
  	
  }
  
	
	@Override
	public Matrix4f invert(){
	 	return getInvertStep(1.0f);
	}
	
	@Override
	public Matrix4f getInvertStep(float step) {
		Vector3f t = trans.scale(step);
		return new Matrix4f(
  			1.0f, 0.0f, 0.0f, -t.x,
  			0.0f, 1.0f, 0.0f, -t.y,
  			0.0f, 0.0f, 1.0f, -t.z,
  			0.0f, 0.0f, 0.0f, 1.0f
  			);
		
	}

	@Override
  public Matrix4f getMatrix() {
	  return getMatrix(trans);
  }
	
	protected Matrix4f getMatrix(Vector3f trans){
		return new Matrix4f(
  			1.0f, 0.0f, 0.0f, trans.x,
  			0.0f, 1.0f, 0.0f, trans.y,
  			0.0f, 0.0f, 1.0f, trans.z,
  			0.0f, 0.0f, 0.0f, 1.0f
  			);
	}

	@Override
  public Matrix4f getStep(float step) {
	  return getMatrix(trans.scale(step));
  }
	
	@Override
	public String toString(){
		return getMatrix().toString();
	}
}
